package com.woniuxy.controller;

import com.woniuxy.entity.DeviceManage;
import com.woniuxy.service.DeviceManageService;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/device")
public class DeviceManageController {
    @Resource
    private DeviceManageService deviceManageService;

    @PostMapping("/queryDevice")
    public ResponseData<?> queryDevice(@RequestBody PageParam<DeviceManage> pageParam){
        Assert.notNull(pageParam,"");
        return deviceManageService.queryDevice(pageParam);
    }


    @PostMapping("/addDevice")
    public ResponseData<?> addDevice(@RequestBody DeviceManage deviceManage){
        Assert.notNull(deviceManage,"");
        return deviceManageService.addDevice(deviceManage);
    }


    @GetMapping("/queryDeviceById/{id}")
    public ResponseData<?> queryDeviceById(@PathVariable("id")Integer id){
        Assert.notNull(id,"");
        return deviceManageService.queryDeviceById(id);
    }


    @PostMapping("/updateDevice")
    public ResponseData<?> updateDevice(@RequestBody DeviceManage deviceManage){
        Assert.notNull(deviceManage,"");
        return deviceManageService.updateDevice(deviceManage);
    }

    @GetMapping("/deleteDevice/{id}")
    public ResponseData<?> deleteDevice(@PathVariable("id")Integer id){
        Assert.notNull(id,"");
        return deviceManageService.deleteDevice(id);
    }
}
